// 导入变量和混合器
@import '@styles/variables.scss';
@import '@styles/mixins.scss';

// 侧边栏容器
.sidebar {
    width: 240px;
    height: 100vh;
    background: #F1F6FB;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 94px;
    transition: all 0.3s ease;

    &.collapsed {
        width: 56px;
        padding: 12px 8px;
    }
}

// 侧边栏头部
.TopSection {
    display: flex;
    flex-direction: column;
    gap: 16px;

    .logo {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 0;
        width: 100%;

        &.collapsed {
            flex-direction: column;
            align-items: center;
            gap: 12px;
        }

        .logo-wrapper {
            display: flex;
            width: 100%;
            justify-content: space-between;
            align-items: center;
            gap: 8px;

            &.collapsed {
                justify-content: center;
            }
        }

        .logo-content {
            display: flex;
            align-items: center;
            gap: 8px;

            .logo-image {
                width: 24px;
                height: 24px;
                border-radius: 50%;
            }

            .logo-text {
                font-family: 'Roboto', sans-serif;
                font-weight: 500;
                font-size: 20px;
                color: #1D2129;
                display: block;

                &.collapsed {
                    display: none;
                }
            }
        }

        .collapse-button {
            width: 24px;
            height: 24px;
            display: flex;
            justify-content: center;
            align-items: center;
            border: none;
            background: transparent;
            color: #4E5969;
            cursor: pointer;
            padding: 0;
            border-radius: 4px;
            transition: all 0.3s ease;
            font-size: 16px;

            &.collapsed {
                transform: rotate(180deg);
            }

            &:hover {
                background: #FFFFFF;
                color: #1D2129;
                box-shadow: 0px 1px 3px rgba(29, 33, 41, 0.1);
            }

            i {
                font-size: 16px;
            }
        }
    }
}


// 新建对话按钮
.new-chat-button {
    width: 100%;
    padding: 9px 16px;
    background: #165DFF;
    border: 1px solid #0E42D2;
    border-radius: 4px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: inset 0px 2px 1px rgba(255, 255, 255, 0.2), inset 0px -2px 1px rgba(3, 32, 112, 0.2);


    &:hover {
        background: #0E42D2;
    }

    i {
        font-size: 16px;
        line-height: 1;
    }

    span {
        display: block;
    }

    &.collapsed {
        padding: 9px 0;
        justify-content: center;

        span {
            display: none;
        }
    }
}

// 导航区域
.nav-section {
    display: flex;
    flex-direction: column;
    gap: 8px;

    .nav-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;

        &.collapsed {
            justify-content: center;

            span {
                display: none;
            }
        }

        i {
            font-size: 16px;
        }
    }

    .nav-items {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .nav-item {
        display: flex;
        align-items: center;
        padding: 9px 12px;
        justify-content: flex-start;
        gap: 8px;
        border-radius: 4px;
        cursor: pointer;
        color: #4E5969;
        background: transparent;
        box-shadow: none;
        transition: all 0.3s ease;
        width: 100%;

        &:hover {
            background: #FFFFFF;
            color: #1D2129;
            background: linear-gradient(90deg, #FFFFFF 0%, #F7F8FA 100%);
        }

        &.active {
            color: #1D2129;
            background: linear-gradient(90deg, #FFFFFF 0%, #F7F8FA 100%);
            box-shadow: 0px 1px 3px rgba(29, 33, 41, 0.1);
        }

        .nav-icon {
            width: 24px;
            height: 24px;
            border-radius: 50%;
        }

        i {
            font-size: 16px;
            line-height: 1;
        }

        &.collapsed {
            padding: 9px 0;
            justify-content: center;
        }
    }
}

// 分割线
.divider {
    height: 1px;
    background: #E5E6EB;
    margin: 16px 0;

    &.collapsed {
        margin: 16px 4px;
    }
}

// 最近对话
.recent-chats {
    display: flex;
    flex-direction: column;
    gap: 8px;

    .recent-chats-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;

        .recent-header-content {
            display: flex;
            align-items: center;
            gap: 8px;
            // color: #4E5969;
            // font-size: 14px;

            i {
                font-size: 16px;
                line-height: 1;
            }
        }

        .more-menu {
            display: flex;
            align-items: center;
            gap: 2px;
            color: #86909C;
            font-size: 12px;
            cursor: pointer;
            position: relative;
            padding: 4px;
            border-radius: 4px;

            &:hover {
                background: rgba(0, 0, 0, 0.04);
            }

            i {
                transition: transform 0.2s ease;
            }
        }

        &.collapsed {
            justify-content: center;

            span {
                display: none;
            }
        }
    }

    .chat-items {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .chat-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 12px;
        justify-content: flex-start;
        border-radius: 4px;
        cursor: pointer;
        position: relative;
        background: transparent;
        transition: all 0.3s ease;
        width: 100%;
        overflow: hidden;
        transition: all 0.3s ease;

        &:hover {
            background: #FFFFFF;
            background: linear-gradient(90deg, #FFFFFF 0%, #F7F8FA 100%);

            .more-icon {
                opacity: 1;
            }
        }

        &.active {
            background: linear-gradient(90deg, #FFFFFF 0%, #F7F8FA 100%);
            box-shadow: 0px 1px 3px rgba(29, 33, 41, 0.1);
        }

        .chat-dot {
            width: 6px;
            height: 6px;
            background: #BEDAFF;
            border-radius: 50%;
            flex-shrink: 0;
        }

        .chat-text {
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 14px;
            color: #4E5969;
        }

        .more-icon {
            position: absolute;
            right: 12px;
            color: #4E5969;
            z-index: 1;
            opacity: 0;
            transition: opacity 0.2s ease;
            width: 24px;
            height: 24px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;

            &:hover {
                background: rgba(0, 0, 0, 0.04);
            }
        }

        &.collapsed {
            padding: 9px 0;
            justify-content: center;

            .more-icon {
                display: none;
            }
        }
    }
}

// 用户信息
.user-profile {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    justify-content: flex-start;
    gap: 8px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s ease;

    &:hover {
        background: #FFFFFF;
    }

    .avatar {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
        color: #4E5969;
    }
}

// 下拉菜单
.dropdown {
    position: fixed;
    background: #FFFFFF;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    padding: 4px;
    min-width: 160px;
    z-index: 1100;

    .dropdown-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        color: #1D2129;
        cursor: pointer;
        font-size: 14px;
        border-radius: 4px;
        transition: all 0.2s ease;

        &:hover {
            background: #F2F3F5;
        }

        &.danger {
            color: #F53F3F;

            &:hover {
                background: rgba(245, 63, 63, 0.06);
            }

            i {
                color: #F53F3F;
            }
        }

        i {
            font-size: 16px;
            color: #4E5969;
        }
    }
}

// 折叠状态样式
.sidebar.collapsed {

    .logo-text,
    .new-chat-button span,
    .nav-header span,
    .chat-text,
    .user-profile span {
        display: none;
    }

    .new-chat-button {
        padding: 9px 0;
    }

    .nav-item {
        padding: 9px 0;
        justify-content: center;
    }

    .chat-item {
        padding: 9px 0;
        justify-content: center;
    }

    .user-profile {
        padding: 8px 0;
        justify-content: center;
    }

    .divider {
        margin: 16px 4px;
    }
}